import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    // 公共子串计算
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s1 = in.next();
        String s2 = in.next();
        getLongString(s1, s2);
    }

    private static void getLongString(String s1, String s2) {
        String shortS = null;
        String longS = null;
        if (s1.length() != s2.length()) {
            shortS = s1.length() < s2.length() ? s1 : s2;
            longS = s1.length() > s2.length() ? s1 : s2;
        } else {
            shortS = s1;
            longS = s2;
        }

        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < shortS.length(); i++) {
            for (int j = shortS.length(); j >= i; j--) {
                if (longS.contains(shortS.substring(i, j))) {
                    if (!map.containsKey(j - i)) {
                        map.put(j - i, i);
                        break;
                    }
                }
            }
        }
        int max = 0;
        for (int x : map.keySet()) {
            if (x >= max) {
                max = x;
            }
        }
        System.out.println(max);
    }


    // 字符串反转
    public static void main3(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        for (int i = s.length()-1; i >= 0; i--) {
            System.out.print(s.charAt(i));
        }
    }


    // 查找两个字符串 a, b 中的最长公共子串
    public static void main2(String[] args) {
        Scanner in = new Scanner(System.in);
        String s1 = in.next();
        String s2 = in.next();
        longString(s1, s2);
    }

    private static void longString(String s1, String s2) {
        if (s2.equals(s1)) {
            System.out.println(s1);
            return;
        }
        String shortS = s1.length() < s2.length() ? s1 : s2;
        String longS = s1.length() > s2.length() ? s1 : s2;
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < shortS.length(); i++) {
            for (int j = shortS.length()-1; j > i; j--) {
                if (longS.contains(shortS.substring(i, j))) {
                    if (!map.containsKey(j-i)) {
                        map.put(j-i, i);
                        break;
                    }
                }
            }
        }
        int max = 0;
        for (int x : map.keySet()) {
            if (x >= max) {
                max = x;
            }
        }
        for (int j = shortS.length(); j > map.get(max); j--) {
            if (longS.contains(shortS.substring(map.get(max), j))) {
                System.out.println(shortS.substring(map.get(max), j));
                break;
            }
        }
    }

    // 汽水瓶
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) {
            int n = in.nextInt();
            if (n == 0) {
                return;
            }
            int count = 0;
            while (n >= 3) {
                n -= 3;
                n += 1;
                count++;
            }
            if (n == 2) {
                count++;
            }
            System.out.println(count);
        }
    }
}
